﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Strom.Core.Network.Packets
{
    public class CreateCharacterRequestResponsePacket : IPacket
    {
        public static byte ID = 5;
        public Graphic.ICreateCharacterForm CreateCharacterForm { get; set; }

        public CreateCharacterRequestResponsePacket(Graphic.ICreateCharacterForm createCharacterForm = null)
        {
            CreateCharacterForm = createCharacterForm;
        }

        public void Unpack(BaseClient client, Packet packet)
        {
            bool success = packet.Reader.ReadBoolean();

            if (success)
                CreateCharacterForm.CreateSuccess();
            else
                CreateCharacterForm.CreateFailed();
        }

        /// <summary>
        /// Resultat de la creation du personnage
        /// </summary>
        /// <param name="client">client en cours</param>
        /// <param name="datas">[0] succès(bool)</param>
        public void Pack(BaseClient client, params object[] datas)
        {
            var pw = new PacketWriter();
            pw.Write((bool)(datas[0]));
            client.Send(pw.CompilePacket(ID));
        }
    }
}
